package pers.cz.business;

import pers.cz.mapper.AutoCollectTestCaseSqlMapper;
import pers.cz.mapper.BusinessKnowLedgeTreeMapper;
import pers.cz.mapper.KnowLedgeBaseBusiMapper;
import pers.cz.model.AutoCollectTestCaseSql;
import pers.cz.model.BusinessKnowLedgeTree;
import pers.cz.model.KnowLedgeBaseBusi;
import pers.cz.pub.AbstractBusiness;

import java.util.List;

/**
 * @program: PostGirl-panent
 * @description: KnowLedgeBaseBusiness
 * @author: Cheng Zhi
 * @create: 2021-07-07 08:53
 **/
public class KnowLedgeBaseBusiness extends AbstractBusiness {

    /**
     * 查询所有的知识库文件
     * @return
     */
    public List<KnowLedgeBaseBusi> queryAllKnowLedgeBaseBusi() {

        List<KnowLedgeBaseBusi> knowLedgeBaseBusiList = this.getMapper(KnowLedgeBaseBusiMapper.class).selectAllKnowLedgeBaseBusi();
        return  knowLedgeBaseBusiList;
    }

    public List<KnowLedgeBaseBusi> queryKnowLedgeBaseBusiByKeyWord(String keyWord) {

        List<KnowLedgeBaseBusi> knowLedgeBaseBusiList = this.getMapper(KnowLedgeBaseBusiMapper.class).selectKnowLedgeBaseBusiByKeyWord(keyWord);

        return knowLedgeBaseBusiList;
    }

    /**
     * 查询所有的图谱节点
     * @return
     */
    public List<BusinessKnowLedgeTree> queryAllBusinessNode() {

        return this.getMapper(BusinessKnowLedgeTreeMapper.class).selectAllBusinessNode();
    }

    /**
     * 新增节点
     * @param businessKnowLedgeTree
     * @return
     */
    public Integer addBusinessNode(BusinessKnowLedgeTree businessKnowLedgeTree) {

        return  this.getMapper(BusinessKnowLedgeTreeMapper.class).insert(businessKnowLedgeTree);
    }

    /**
     * 修改节点
     * @param businessKnowLedgeTree
     * @return
     */
    public Integer updateBusinessNode(BusinessKnowLedgeTree businessKnowLedgeTree) {

        return  this.getMapper(BusinessKnowLedgeTreeMapper.class).updateByPrimaryKeySelective(businessKnowLedgeTree);
    }

    /**
     * 删除节点
     * @param id
     * @return
     */
    public Integer deleteBusinessNode(Integer id) {

        return  this.getMapper(BusinessKnowLedgeTreeMapper.class).deleteByPrimaryKey(id);
    }

    /**
     * 获取所有的接口编号
     * @return
     */
    public List<String> getAllBusiCode() {

        return this.getMapper(AutoCollectTestCaseSqlMapper.class).selectBusiCodeDistinct();
    }

    /**
     * 根据接口获取所有sql
     * @param busiCode
     * @return
     */
    public List<AutoCollectTestCaseSql> getAllSqlByBusiCode(String busiCode) {

        return this.getMapper(AutoCollectTestCaseSqlMapper.class).selectSqlByBusiCode(busiCode);
    }
}
